package com.healthcloud.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.healthcloud.dao.DepartmentMapper;
import com.healthcloud.entity.Department;
import com.healthcloud.service.DepartmentService;
import com.healthcloud.utils.PageParam;

/**
 * Created by houxianghua on 2015/7/10.
 */
@Service
@Transactional
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;


    @Override
    public Department get(int id) {
        return departmentMapper.get(id);
    }

    @Override
    public List<Department> findByEntityAll(Department entity) {
        return departmentMapper.findByEntityAll(entity);
    }

    @Override
    public List<Department> search(Department entity, PageParam pageParam) {
//        entity.setIsDel(false);
        return departmentMapper.search(entity, pageParam);
    }

    @Override
    public int count(Department entity) {
//        entity.setIsDel(false);
        return departmentMapper.count(entity);
    }

    @Override
    public int save(Department entity) {
//        entity.setIsDel(false);
        return departmentMapper.save(entity);
    }

    @Override
    public int update(Department entity) {
//        entity.setIsDel(false);
        return departmentMapper.update(entity);
    }

    @Override
    public int delete(int id) {
        return departmentMapper.delete(id);
    }

    @Override
    @Transactional
    public int deletes(int[] ids) {
        int j = 0;
        for (int i = 0; i < ids.length; i++) {
            j = delete(ids[i]);
        }
        return j;
    }

    @Override
    public int logicalDelete(int id) {
        return departmentMapper.logicalDelete(id);
    }

    @Override
    @Transactional
    public int logicalDeletes(int[] ids) {
        int j = 0;
        for (int i = 0; i < ids.length; i++) {
            j = logicalDelete(ids[i]);
        }
        return j;
    }
}
